home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1984 July to December
/
Ahoy_Magazine_84-Jul-Dec_1984_Double_L_unofficial.d64
/
emerald elephant
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
15KB
|
430 lines
1 rem "the emerald elephant of cipangu"
2 rem a mini-adventure, just to show how it's done. for the 64--it won't fit
3 rem on an unexpanded vic. if you have an expanded vic, change the text so it
4 rem will fit properly on the screen.
5 rem
6 rem rd=room direction table. cw$=command word table. rn$=room names
7 rem ks=keystroke table. tn$="thing" name table. ts$="thing" short names
8 rem tl="thing" location table (room #). vs=visit table: non-zero if visited.
9 rem
10 dim rd(14,8),cw$(16),rn$(60),ks(64),tn$(9),ts$(9),tl(9),vs(14)
20 gosub 1000
25 gosub 970
27 rem
28 rem set up blank lines and position strings
29 rem
30 bl$=" "
31 rl$="":for i=1 to 78:rl$=rl$+" ":next:rl$=rl$+""
32 tl$="":for i=1 to 78:tl$=tl$+" ":next:tl$=tl$+""
33 dl$=""
34 t$=" within your reach is . . . ."
35 c$=chr$(13)
60 print "[147]careful!"c$c$"just through those trees is the castle"
61 print "of darkness."c$c$"once you see it, you'll be struck blind"
62 print "until you leave."c$c$"but hidden in a secret treasure room"
63 print "somewhere in the castle is the emerald"
64 print "elephant of cipangu. the touch of the"
65 print "elephant will give you the priceless"
66 print "gift of far sight, which will let you"
67 print "see to the ends of the earth. whatever"
68 print "place you think of, you will see."c$c$"(press any key)":gosub 990
69 print "[147]as for me, i seem to you to be merely a"
70 print "firefly. i am really something else"
71 print "entirely, and once you get the elephant"
72 print "and leave the castle, you will see me asi really am."c$
73 print "will you come with me? i'll be your"
74 print "eyes, while you decide where we should go."c$
75 print "you can press a single key to go u[154]p,"
76 print "d[154]own, i[154]n, o[154]ut, n[154]orth, s[154]outh, e[154]ast, w[154]est, or b[154]ack."c$
77 print "you can also t[154]ake something, l[154]eave it"
78 print "behind, tell me to p[154]eer closely at"
79 print "things around us, check to see what we"
80 print "have g[154]ot, q[154]uit, or ask for h[154]elp (?[154])."c$c$"(press any key)"
81 gosub 990
87 rem
88 rem initial position
89 rem
90 xx=1:xr=1:pr=1:gosub 350
97 rem
98 rem main loop. get keystroke first
99 rem
100 gosub 990
105 print bl$cw$(cm):if cm=0 then 100
107 rem
108 rem direction commands
109 rem
110 if cm<9 then gosub 300:goto 130
117 rem
118 rem all other commands
119 rem
120 c=cm-8:on c gosub 390,400,450,550,470,190,500,500
127 rem
128 rem check for victory
129 rem
130 if pr=1 and tl(9)=0 then for i=0 to 999:next:goto 940
140 print bl$cw$(cm):goto 100
187 rem
188 rem "quit" routine
189 rem
190 print "[147]press q to quit":gosub 990:if cm=14 then end
195 goto 350
297 rem
298 rem movement handler
299 rem
300 xx=xr:xr=pr:pr=rd(xr,cm)
302 rem
303 rem check for special cases
304 rem
310 if xr=7 and tl(0)=0 and pr=56 then gosub 900:pr=1:goto 350
315 if pr=14 then gosub 905:goto 350
320 if pr=56 and xr=4 and tl(2)=0 then gosub 920:pr=5:goto 350
325 if pr=4 and xr=5 and tl(9)=0 then gosub 925:goto 350
342 rem
343 rem is it an illegal movement?
344 rem
345 ds$="":if pr>49 then ds$=rn$(pr):pr=xr:xr=xx
346 rem
347 rem * * * return point * * *
348 rem table search--are there any "things" in the room?
349 rem
350 tn$="":for i=0 to 9:if tl(i)=pr then tn$=tn$+tn$(i)+", "
355 next:l=len(tn$):if l>1 then tn$=left$(tn$,l-2)
360 tt$=t$:if tn$="" then tt$=""
362 rem
363 rem set room name to present room
364 rem
365 rn$=rn$(pr)
367 rem
368 rem is it the first visit to the room?
369 rem
370 if vs(pr)=0 then vs(pr)=1:goto 550
372 rem
373 rem clear screen and print room name and message
374 rem
375 print "[147]"cw$(cm)rl$rn$tt$tl$tn$dl$ds$
380 return
387 rem
388 rem back command handler
389 rem
390 xx=pr:pr=xr:xr=xx:rn$=rn$(pr):ds$="":goto 350
397 rem
398 rem "take" routine
399 rem
400 i=0
405 if tl(i)=pr then tl(i)=0:pp$=pp$+chr$(i):ds$="got it!":goto 350
410 if len(pp$)>5 then gosub 450
415 i=i+1:if i>9 then ds$="there's nothing here.":goto 350
420 goto 405
447 rem
448 rem "leave" routine
449 rem
450 if len(pp$)<1 then ds$="you don't have anything now.":goto 350
455 lt=asc(left$(pp$,1)):pp$=right$(pp$,len(pp$)-1)
460 tl(lt)=pr:ds$="":goto 350
467 rem
468 rem "got" handler
469 rem
470 if pp$="" then ds$="you've got nothing right now.":goto 350
475 ds$="you've got:"+c$+c$
480 for i=1 to len(pp$):ds$=ds$+ts$(asc(mid$(pp$,i,1)))+c$:next
485 goto 350
497 rem
498 rem "help" routine
499 rem
500 print "[147]"c$c$"there are 9 possible directions:"
501 print "n = north"c$"s = south"c$"e = east"c$"w = west"c$"u = up"
502 print "d = down"c$"i = in"c$"o = out"c$"b = back to previous room"c$
503 print "other commands are:"c$c$"t = take the first object listed"
504 print "l = leave behind whatever you've been carrying longest"
505 print "p = peer at surroundings"c$"g = list what we've got with us"
506 print "q = quit"c$"h = help"c$"? = help"c$
507 print "(press any key)";:gosub 990:print "[147]":goto 350
547 rem
548 rem "peer" jump table
549 rem
550 print "[147]"dl$
555 on pr gosub 600,620,640,660,680,700,720,740,760,780,800,820,840,860
560 print bl$cw$(cm)rl$rn$tt$tl$tn$
565 return
597 rem
598 rem main gate description
599 rem
600 print "we are standing on the bridge leading"
601 print "to the huge wooden gate of the castle."c$
602 print "to the north is the deep forest. a"
603 print "path leads around the castle to the"
604 print "east and west. the walls are very high"
605 print "and i can't see anyone at all."
615 return
617 rem
618 rem west of castle
619 rem
620 print "the meadow is full of rabbits, so be"
621 print "careful where you step. the forest is"
622 print "thick to the west. a path leads around"
623 print "the castle to the north and south."c$
624 print "the stones of the castle wall are slick"
625 print "and covered with moss."c$
626 print "listen--you can hear a horse whinnying."
635 return
637 rem
638 rem east of castle
639 rem
640 print "please don't dance around so much!"c$
641 print "we're on a narrow ledge along the east"
642 print "edge of the castle. it ends just a few"
643 print "yards to the south."c$
644 print "over the edge it's a sheer drop for at"
645 print "least two thousand feet. the edge is"
646 print "crumbling a little, so if you don't"
647 print "mind, couldn't we just go back?"
655 return
657 rem
658 rem south of castle
659 rem
660 print "we're in a grove of trees on a narrow"
661 print "wedge of land just south of the castle."c$
662 print "the land slopes down toward the founda-"
663 print "tion of the castle to the north, and to"
664 print "the south it slopes up to a sudden"
665 print "drop-off. there's a steep cliff to the east, too."c$
666 print "there's a column of smoke rising above the castle wall."
675 return
677 rem
678 rem kitchen
679 rem
680 print "the kitchen fire is burning hotly, but"
681 print "there's no one in the room."c$
682 print "a large open doorway leads out into the"
683 print "courtyard to the north and west. the"
684 print "doorway is filled with flies. not"
685 print "fireflies--the lower-class kind."c$
686 print "to the east there's another door, and"
687 print "to the south there's a gap where one"
688 print "stone has been pulled out of the"
689 print "foundation. it's the secret postern"
690 print "door, the one we crawled through."c$
691 print "there's a large table in the middle of"
692 print "the room, with more food on it than a"
693 print "normal person could eat in a week.";
695 return
697 rem
698 rem courtyard
699 rem
700 print "we're in an open area in the center of"
701 print "the castle. the door of the great hall is just east of us."c$
702 print "the kitchen is to the south and there are stables to the west."c$
703 print "to the north is the gatehouse, a thick"
704 print "building that surrounds and protects themain gate."c$
705 print "the dirt in the courtyard is smooth, as"
706 print "if no one had ever walked here. the onlyfootprints are yours."
715 return
717 rem
718 rem gatehouse
719 rem
720 print "we're high up in the gatehouse, by the"
721 print "windlass that controls the gate. it's"
722 print "stuck--all your strength can't budge it.sorry i can't help."c$
723 print "there are short stairways leading up to"
724 print "the walls, and another stairway leading"
725 print "down to the courtyard below us."c$
726 print "hanging from a spike on the wall is a"
727 print "single elephant's tusk. it's too high to reach."
735 return
737 rem
738 rem on the walls
739 rem
740 print "we're on the castle walls, behind the"
741 print "crenellation. we can walk all the way"
742 print "around the castle. the only places we"
743 print "can get off are the gatehouse and the"
744 print "tower that rises above the great hall."c$
745 print "please don't stay up here too long."
746 print "there are birds coming closer. they"
747 print "look to me like the insect-eating kind,"
748 print "and a firefly like me can't hide very easily."
755 return
757 rem
758 rem great hall
759 rem
760 print "we're in the great hall of the castle."
761 print "a large doorway in the north leads to"
762 print "the courtyard, while a small door to the west goes to the kitchen."
763 print c$"there are tables and benches around the"
764 print "room, a huge fire pit in the middle, anda throne at one end."
765 print c$"a large tapestry on the wall proclaims"
766 print "that this is the residence of the count of obscurity."c$
767 print "a small stairway goes up along one wall"
768 print "and behind the throne there's a trap"
769 print "door that someone has carelessly left"
770 print "half open.";
775 return
777 rem
778 rem count's chamber
779 rem
780 print "the large curtained bed looks recently"
781 print "slept in, and the hearth coals are stillglowing."c$
782 print "small doors lead onto the walls to the"
783 print "north and west, while small cupboard"
784 print "doorways seem to lurk behind every"c$"tapestry."c$
785 print "a stairway in one corner goes down, and"
786 print "a narrow ladder leads up through the"
787 print "ceiling. i think i can hear footsteps"
788 print "above us. please don't go up there."
795 return
797 rem
798 rem tower lookout
799 rem
800 print "we're at the highest point of the"c$"castle."c$
802 print "ignore the sound of someone walking"
803 print "around. it isn't anybody--just an"
804 print "empty suit of armor that keeps walking"
805 print "around and around the edge of the tower."
806 print "at least i think it's empty."c$
807 print "would you mind terribly if we just went back down the ladder?"
815 return
817 rem
818 rem the stables
819 rem
820 print "the floor of the stable is wooden, and"
821 print "some of the boards are missing--test"
822 print "each step before you put your weight on"
823 print "it. it looks like a long way down if"
824 print "you fall through. or is there somethingunder the stable?":print
825 print "there's that whinnying sound. it seems"
826 print "to be coming from that stall, but the"
827 print "stall is empty.":print
828 print "i don't mean to sound timid, but the"
829 print "only way out of here is the east door tothe courtyard."
835 return
837 rem
838 rem the dungeons
839 rem
840 print "we're down in the dungeons, and the"
841 print "only light down here is me.":print
842 print "and i'm not all that bright.":print
843 print "lots of little cells everywhere. mostly"
844 print "empty. none of them with any living"
845 print "residents. unless you count rats.":print
846 print "i don't see any death traps, but then, ican't see much of anything."
855 return
857 rem
858 rem the treasure room
859 rem
860 print "we made it! there are coins and ingots and jewels everywhere!"
861 print:print "paintings, too. and sculptures.":print
862 print "no, don't take any of it! it's all"
863 print "cursed! just the elephant of cipangu--"
864 print "that's all you can take with you, if"
865 print "you want to live long and prosper."
875 return
900 rd(7,1)=1:rd(7,8)=1:rd(1,2)=7:rd(1,7)=7
901 ds$="using the golden key, you unlock the turnstile and open the gate"
902 return
905 if tl(4)=0 and tl(5)=0 and tl(8)=0 then 910
906 pr=xr:xr=xx:ds$=rn$(56):return
910 print "[147]"dl$"don't be so clumsy! you spilled some"
911 print "ale from the flagon on the pillow and"
912 print "the mouse suddenly woke up and drank it"
913 print "and--wait a minute--the mouse is"
914 print "speaking. it's reading some ancient"
915 print "words written in the embroidery of the"
916 print "pillow--and there's a secret door,"
917 print "beginning to glow brightly--it's the"
918 print "treasure room! let's go in!"c$c$"(press a key)"
919 gosub 990:ds$="":return
920 print "[147]"dl$"there's a crack in one foundation stone"
921 print "and if you just pry a little with the"
922 print "butcher knife--yes, that's it. get yourback into it."c$
923 print "you did it! we can crawl under here andget inside.":print
924 print "(press a key)":ds$="":gosub 990:return
925 pr=5:xr=xx
926 ds$="you can't get through with the elephant.i thought you knew that."
927 ds$=ds$+c$+"only the main gate will let us pass."
928 return
937 rem
938 rem victory handler
939 rem
940 print "[147]we made it!":print:print "we're outside the castle with the"
941 print "emerald elephant of cipangu. now you"
942 print "can see again, and i have recovered my"
943 print "true form. i know i'm incredibly good-"
944 print "looking, but don't bother asking me for"
945 print "a date--you're fine for exploring"
946 print "castles, but i'm engaged to marry"
947 print "somebody with royal blood and a fortune"
948 print "bigger than the national debt. you've"
949 print "been sweet, though. thanks a bunch!":print:print "bye!"
950 poke 198,0:end
967 rem
968 rem randomly choose location of treasure room
969 rem
970 r=int(10*rnd(9)):if r>2 then r=3
971 if r=1 then r=0
972 on r goto 975,980,985
975 x=2+int(2*rnd(9)):rd(10,x)=14:return
980 rd(12,6)=14:return
985 x=1+int(8*rnd(9)):r=13:if rd(r,x)=55 then rd(r,x)=14:return
986 goto 985
990 a=peek(197):if a=64 then 990
995 cm=ks(a):return
997 rem
998 rem set up command word array
999 rem
1000 for i=0 to 16:read a$:cw$(i)=a$:next
1010 data "what?","north","south","east","west","up","down","in","out","back"
1015 data "take","leave","peer","got?","quit","help","help"
1047 rem
1048 rem set up keystroke array
1049 rem
1050 for i=0 to 64:ks(i)=0:next
1055 for i=1 to 16:read a:ks(a)=i:next
1060 data 39,13,14,9,30,18,33,38,28,22,42,41,26,62,29,55
1097 rem
1098 rem set up rd (room direction table) and rn$ (room name table)
1099 rem
1100 for i=1 to 14:read a$:rn$(i)=a$:for j=1 to 8:read a:rd(i,j)=a:next:next
1110 data "castle main gate",52,53,3,2,51,50,53,50
1115 data "meadow west of castle",1,4,51,52,51,50,51,50
1120 data "ledge east of castle",1,54,54,51,51,51,51,50
1125 data "grove south of castle",51,54,54,2,51,56,53,50
1130 data "kitchen",6,4,9,6,50,13,9,6
1135 data "courtyard",7,5,9,12,7,5,9,7
1140 data "gatehouse",56,6,8,8,8,6,6,56
1145 data "on the walls",7,10,10,7,57,51,7,50
1150 data "great hall",6,50,50,5,10,13,5,6
1155 data "count's chamber",8,55,55,8,11,9,50,8
1160 data "tower top",54,54,54,54,57,10,50,50
1165 data "the stables",50,50,6,50,50,55,50,6
1170 data "the dungeons",55,55,55,55,9,55,50,50
1175 data "treasure room",50,50,50,50,50,50,50,50
1197 rem
1198 rem set up rn$ values for illegal movement directions
1199 rem
1200 for i=50 to 57:read a$:rn$(i)=a$:next
1210 data "sorry, but we can't go that way"
1215 data "it's too steep for us to climb"
1220 data "we'll just get lost if we wander in the woods"
1225 data "i'm knocking, but nobody answers"
1230 data "are you trying to get us killed?"
1235 data "i searched there, found nothing, and came back"
1240 data "we don't have what it takes to get in there"
1245 data "up from here? do you think you can fly?"
1297 rem
1298 rem set up the "thing" table by naming objects and putting them in rooms
1299 rem
1300 for i=0 to 9:read a$,b$:tn$(i)=a$:ts$(i)=b$:next
1310 data "a golden key","key","a loaf of rye bread","bread"
1315 data "a butcher knife","knife","a pocket sundial","sundial"
1320 data "a delicately embroidered pillow","pillow"
1325 data "a limp, motionless mouse","mouse"
1330 data "a parchment codex","codex","an orange rind","rind"
1335 data "a flagon of ale","flagon"
1340 data "the emerald elephant of cipangu","elephant"
1347 rem
1348 rem put each thing in its room
1349 rem
1350 for i=0 to 9:read a:tl(i)=a:next
1355 data 3,5,4,6,10,13,9,11,7,14
1990 return